
function scroll(ops = {}) {
    scrollbox = ops.scrollbox;
    imgbox1 = ops.imgbox1;
    imgbox2 = ops.imgbox2;
    
    ajax("http://localhost:3000/newlife", (res) => {
        res = JSON.parse(res).data;
        imgs = res;
        dong()
    },false)

    function dong(){
    for (let i = 0; i < imgs.length; i++) {
        let img = document.createElement("img");
        img.alt = "图片加载失败";
        img.src = imgs[i].img_001;

        let a = document.createElement("a")
        a.href = "#"
        a.innerHTML = `<img src="${img.src}" alt="">`
        imgbox1.appendChild(a)
    }
    for (let i = 0; i < imgs.length; i++) {
        let img = document.createElement("img");
        img.alt = "图片加载失败";
        img.src = imgs[i].img_001;
        let a = document.createElement("a")
        a.href = "#"
        a.click()
        a.innerHTML = `<img src="${img.src}" alt="">`
        imgbox2.appendChild(a)
    }
    let ss = imgbox2.offsetLeft;
    function scroll() {
        imgbox1.style.left = (imgbox1.offsetLeft - 1) + "px";
        imgbox2.style.left = (imgbox2.offsetLeft - 1) - ss + "px";
        if (imgbox1.offsetLeft <= -ss) { imgbox1.style.left = ss + "px"; }
        if (imgbox2.offsetLeft <= -ss) { imgbox2.style.left = 0 + "px"; }
    }
    var time;
    function set() {
        time = setInterval(e => {
            scroll();
        }, 15)
    }
    set();
    scrollbox.onmouseenter = function () {
        clearInterval(time);
    }
    scrollbox.onmouseleave = function () {
        set();
    }
    }
}
